package com.noahsloan.nutils.streams.clocked;

/**
 * A rate calculator determines the data rate based on measurements given to it.
 * Implementations are responsible for determining the amount of time that has
 * passed, although the general purpose {@link Clocked} and {@link TimeSource}
 * interfaces are recommended to aid in the portability of calculators.
 * 
 * @author noah
 * 
 */
public interface RateCalculator {

    /**
     * Used to report that bytes have been read/written.
     * 
     * @param count
     *            the number of bytes read/written.
     * @return count, unmodified
     */
    long storeMeasurement(long count);

    /**
     * Stop taking new measurements.
     */
    void close();

    /**
     * Returns the data rate.
     * 
     * @return the data rate in bytes per millisecond.
     */
    double getRate();

}